package com.cowcowit.mybatisplus.generator;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;

public class FastAutoGenerator01_seata_order {
    public static void main(String[] args) {

        // 创建代码生成器
        FastAutoGenerator fastAutoGenerator = FastAutoGenerator.create(
                "jdbc:mysql://localhost:3306/seata_order",
                "root",
                "12345678");

        // 全局配置
        FastAutoGenerator globalConfig = fastAutoGenerator.globalConfig(builder -> {
            builder.author("whboy") // 设置作者
                    .disableOpenDir()
                    .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java"); // 指定输出目录
        });

        // 包配置
        FastAutoGenerator packageConfig = globalConfig.packageConfig(builder -> {
            builder.parent("com.cowcowit")
                    .moduleName("springcloud");

        });
        // 策略配置
        FastAutoGenerator strategyConfig = packageConfig.strategyConfig(builder -> {
            builder.addTablePrefix("t_", "c_", "tbl_")
                    .entityBuilder()
                    .enableLombok();
        });
        // 使用Freemarker 引擎模板，默认的是Velocity引擎模板
        FastAutoGenerator templateEngine = strategyConfig.templateEngine(new FreemarkerTemplateEngine());
        templateEngine.execute();
    }
}
